package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.OrderStation;
import com.indusfo.spc.service.OrderStationService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/11/26 9:34
 * @Version 1.0
 */

@Controller
@RequestMapping(value = "/service/orderStation")
public class OrderStationController {


    @Autowired
    private OrderStationService orderStationService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryOrderStation")
    @ResponseBody
    public JSONObject queryOrderStation(OrderStation orderStation) {
        JSONObject json = orderStationService.queryOrderStation(orderStation);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertOrderStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertOrderStation(OrderStation orderStation) {
        JSONObject json = orderStationService.insertOrderStation(orderStation);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateOrderStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateOrderStation(OrderStation orderStation) {
        JSONObject json = orderStationService.updateOrderStation(orderStation);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteOrderStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteOrderStation(@RequestParam("orderStationIds") List<Integer> orderStationIds, Integer dataState) {
        dataState = 2;
        JSONObject json = orderStationService.deleteOrderStation(orderStationIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedOrderStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedOrderStation(@RequestParam("orderStationIds") List<Integer> orderStationIds, Integer dataState) {
        JSONObject json = orderStationService.deleteOrderStation(orderStationIds, dataState);
        return json;
    }

}
